<h3 class="text-danger text-bold text-center">分组、域名、属性、修改，都同步更新到推广模板，请慎重修改！</h3>
@if(empty($id))
<div class="form-group">
    <label for="tagDid" class="col-md-3 control-label">所属域名</label>
    <div class="col-md-5">
        <select class="form-control" name="did" id="tagDid"
                onchange="inputForWrite(this)">
            @foreach ($domainList as $row)
                <option gid="{{ $row['gid'] }}" gname="{{ $row['gname'] }}" uid="{{ $row['uid'] }}"
                        username="{{ $row['username'] }}" value="{{ $row['id'] }}"
                        @if ($row['id'] === $did) selected="selected" @endif>{{ $row['domain'] }}</option>
            @endforeach
        </select>
    </div>
</div>
@else
<div class="form-group">
    <label for="tagDomain" class="col-md-3 control-label">所属域名</label>
    <div class="col-md-5">
        <input type="text" class="form-control" name="domain" id="tagDomain" value="{{ $domain }}" readonly>
        <input type="hidden" class="form-control" name="did" id="tagDomain" value="{{ $did }}" readonly>
    </div>
</div>
@endif
<div class="form-group">
    <label for="tagType" class="col-md-3 control-label">属性类型</label>
    <div class="col-md-5">
        <select class="form-control" name="type" id="tagType"
                onchange="$('#type_value').val($(this).find('option:selected').attr('typeValue'));">
            @foreach (config('app.attribute_type') as $key => $valueAttr)
                <option value="{{ $key }}" typeValue="{{ $valueAttr }}"
                        @if ($key === $type) selected="selected" @endif>{{ $key }}</option>
            @endforeach
        </select>
        <input type="hidden" id="type_value" name="type_value"
               value="{{ empty($type_value) ? config('app.attribute_type')['单行文本'] : $type_value}}">
    </div>
</div>
<div class="form-group">
    <label for="tagName" class="col-md-3 control-label">属性名称</label>
    <div class="col-md-5">
        <input type="text" class="form-control" name="name" id="tagName" value="{{ $name }}" autofocus>
    </div>
</div>

<div class="form-group">
    <label for="tagValue" class="col-md-3 control-label">属性值</label>
    <div class="col-md-5">
        <textarea class="form-control" rows="3" name="value" id="tagValue">{{ $value }}</textarea>
    </div>
</div>

<div class="form-group">
    <label for="tagCallTag" class="col-md-3 control-label">调用标签</label>
    <div class="col-md-5">
        <input type="text" class="form-control" name="call_tag" id="tagCallTag" value="{{ $call_tag }}" autofocus>
    </div>
</div>
<div class="form-grop">
    <div class="col-md-8">
        <input type="hidden" id="domain" name="domain" value="{{ empty($domain)? $domainList[0]['domain']:$domain }}">
        <input type="hidden" id="username" name="username"
               value="{{ empty($username)? $domainList[0]['username']:$username }}">
        <input type="hidden" id="uid" name="uid" value="{{ empty($uid)? $domainList[0]['uid']:$uid }}">
        <input type="hidden" id="gid" name="gid" value="{{ empty($gid)? $domainList[0]['gid']:$gid }}">
        <input type="hidden" id="gname" name="gname" value="{{ empty($gname)? $domainList[0]['gname']:$gname }}">
    </div>
</div>
<script type="text/javascript">
    function inputForWrite(thisObj) {
        // hidden
        $obj = $(thisObj).find('option:selected');
        $('#domain').val($obj.text());
        $('#username').val($obj.attr('username'));
        $('#uid').val($obj.attr('uid'));
        $('#gid').val($obj.attr('gid'));
        $('#gname').val($obj.attr('gname'));
    }
</script>